package com.ccp.dev.qbdms.controller;

import com.alibaba.fastjson.JSON;
import com.ccp.dev.core.basic.annotion.Action;
import com.ccp.dev.core.basic.consts.UrlConstants;
import com.ccp.dev.core.basic.internationalization.SysBaseController;
import com.ccp.dev.core.basic.web.query.QueryFilter;
import com.ccp.dev.qbdms.consts.ZhiLiangConst;
import com.ccp.dev.qbdms.service.WQbdQualityCheckStatisticsService;
import com.ccp.dev.system.service.DictionaryService;
import java.util.Date;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
/**
 * 请将此名称添加到日志开关
 */
@Action(customModel = "质量检验统计")
@RequestMapping("/qbdms/wQbdQualitycheckStatistics")
public class WQbdQualitycheckStatisticsController extends SysBaseController {


	@Resource
	private WQbdQualityCheckStatisticsService wQbdQualityCheckStatisticsService;

	@Resource
	private DictionaryService dictionaryService;

	/**
	 * 功能描述: 跳转到首页
	 *
	 * @return: java.lang.String
	 * @auther: 于金
	 * @date: 2020-05-12 10:39:53
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/wQbdQualitycheckStatisticsCharts")
	@Action(description = "跳转到质量检验统计首页", exectype = "页面跳转日志")
	public String viewList(HttpServletRequest request, ModelMap modelMap) {
		QueryFilter queryFilter = new QueryFilter(request, true);
		String nowyear = DateFormatUtils.format(new Date(), "yyyy");
		modelMap.put("nowyear", nowyear);
		//统计类型
		modelMap.put("tjlxzljy", JSON.toJSONString(dictionaryService.getByNodeKey("tjlxzljy")));
		//横坐标
		modelMap.put("hzb", JSON.toJSONString(dictionaryService.getByNodeKey("hzb")));
		// 添加通用查询条件
		return "wQbdQualitycheckStatistics/wQbdQualitycheckStatisticsCharts";
	}

	@RequestMapping("/getChartData")
	@ResponseBody
	@Action(description = "查询数据信息", exectype = "查询日志")
	public Object getChartData(HttpServletRequest request) {
		QueryFilter queryFilter = new QueryFilter(request, false);
		// 添加通用查询条件
		ZhiLiangConst.addQueryFilter(queryFilter);
		return success(wQbdQualityCheckStatisticsService.getChartData(queryFilter));
	}
}
